	<template>
		<view class="content"
			:style="'background: url('+ c_imgPath + 'mine/indexBg.png'+ ') repeat-y 0 0 / 100% auto;'">
			<view class="header">
				<view class="qiehuan">
					<view @click="tabChange(i+1)" v-for="(v,i) in arr" :key="i">
						<view :class="show==i+1?'xzs':'wzs'">{{v}}</view>
						<view class="qiehuan_line" v-if="show==i+1">
							<image :src="c_imgPath+'mine/text_bom.png'"></image>
						</view>
					</view>
				</view>
			</view>
			<!-- 内容 -->
			<mescroll-body
				ref="mescrollRef"
				@init="mescrollInit"
				@down="downCallback"
				@up="getList"
				:down="downOption"
				:up="upOption"
				>
				<view class="coupon">
					<view class="item" 
						:class="show == 2 ?'item_sel':''"
						:style="'background: url('+ c_imgPath + 'mine/coupon_bg.png'+ ') repeat-y 0 0 / 100% 100%;'"
						v-for="(item,index) in listData" 
						:key="index">
						<!-- <view class="item_top">{{item.goods_title}}</view> -->
						<view class="item_box">
							<view class="item_left">
								<view class="left_num">￥<text>{{item.money}}</text></view>
								<view class="left_text">满{{item.out_money}}减</view>
							</view>
							<view class="xian"></view>
							<view class="item_center">
								<view class="center_title hang2">{{item.goods_title}}</view>
								<!-- {{item.title}} -->
								<view class="center_time">
									<view class="text ">{{item.title}}</view> 
									<view class="text1">有效期至{{item.end_time}}</view>
								</view>
							</view>
							<view class="item_btn" @click="toDetail()" v-if="show == 1">使用</view>
							<view class="item_btn" v-if="show == 2">已使用</view>
						</view>
					</view>
				</view>
			</mescroll-body>
		</view>
	</template>

<script>
export default {
	data() {
		return {
			z_imgUrl: this.$z_imgUrl,
			c_imgPath: 'https://qt.yhemall.com/',
			arr: ['可使用', '已使用'],
			show: 1,
			
			// 下拉刷新的配置(可选, 绝大部分情况无需配置)
			downOption: {
				auto: false
			},
			// 上拉加载的配置(可选, 绝大部分情况无需配置)
			upOption: {
				auto: true,
				page: {
				size: 10 // 每页数据的数量,默认10
				}
			},
			listData: [],

			// 是否可以支付
			noClick: true
		}
	},
	onLoad(e) {
		
	},

	methods: {
		toDetail(){
			uni.switchTab({
				url:'/pages/shouye/index'
			})
		},
		tabChange(v) {
			this.show = v
			this.listData = []
			this.mescroll.resetUpScroll()
			this.mescroll.scrollTo(0, 0)
		},
		getList({ num, size }) {
			this.req({
				url: 'coupon',
				data: {
					page: num,
					per_page: size,
					type:this.show
				},
				Loading: true,
				success: res => {
				if (res.status == 1) {
					if (num == 1) {
						this.listData = []
					}
					this.listData = [...this.listData, ...res.data.list]
					this.mescroll.endByPage(res.data.list.length, res.data.last_page)
				}
				}
			})
		}
	}
}
</script>

<style lang="scss">
	
	.coupon{
		width: 690rpx;
		margin: 20rpx auto;
		/* 	background: #11141D;
		box-shadow: 0px 0px 10rpx 0px rgba(150, 255, 254, 0.7);
		padding: 0 30rpx; */
		padding-top: 30rpx;
		box-sizing: border-box;
		/* border-radius: 20rpx; */
		.item{
			padding: 20rpx;
			box-sizing: border-box;
			// border: 1px solid #5D5868;
			// background: linear-gradient(0deg, #2D2C4A 0%, #48495B 100%);
			border-radius: 10rpx;
			margin-bottom: 40rpx;
			.item_top{
				font-size: 28rpx;
				color: #FFFFFF;
				text-shadow: 0px 0px 11px rgba(49,117,255,0.7);
				margin-bottom: 10rpx;
			}
			.item_box{
				display: flex;
				align-items: center;
				color: #FFFFFF;
				text-shadow: 0px 0px 11px rgba(49,117,255,0.7);
			}
			.item_left{
				text-align: center;
				padding: 0 30rpx;
				flex: 0.3;
				.left_num{
					font-size:30rpx ;
					text{
						font-size: 54rpx;
					}
				}
				.left_text{
					font-size: 20rpx;
					// margin-top: 10rpx;
				}
			}
			.xian{
				height: 80rpx;
				width: 1px;
				border-right: 1px solid #CCCCCC;
			}
			.item_center{
				flex: 1;
				margin-left: 20rpx;
				.center_title{
					font-size: 28rpx;
				}
				.center_time{
					font-size: 20rpx;
					margin-top: 20rpx;
					display: flex;
					align-items: center;
					.text{
						margin-right: 10rpx;
					}
					.text1{
						flex: 1;
					}
				}
			}
			.item_btn{
				font-size: 28rpx;
				border: 1px solid #999999;
				padding: 5rpx 15rpx;
				border-radius: 5rpx;
			}
		}
		.item_sel{
			color: #999999;
			text-shadow: 0px 0px 0px rgba(49,117,255,0.7);
			.item_btn{
				border: 1px solid #999999;
				padding: 5rpx 15rpx;
				border-radius: 5rpx;
			}
		}
	}
	
	
	
	
	
	
	
	.qiehuan {
		display: flex;
		justify-content: space-between;
		/* align-items: center; */
		margin-top: 16rpx;
		width: 400rpx;
	}
	
	.qiehuan_line {
		
	}
	
	.qiehuan_line>image {
		width: 94rpx;
		height: 24rpx;
	}
	
	.qiehuan>view {
		flex: 1;
		text-align: center;
	}
	
	.wzs {
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #9E99E3;
	}
	
	.xzs {
		font-size: 32rpx;
		background: linear-gradient(0deg, #B75AFF 0%, #E7CBFF 100%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
		font-weight: bold;
	
	}
	
	.header {
		width: 750rpx;
		/* height: 176rpx; */
		padding-bottom: 30rpx;
		background: #09081C;
		font-size: 28rpx;
		color: #333333;
		box-sizing: border-box;
		position: fixed;
		/* #ifdef MP */
		top: 0;
		/* #endif */
		/* #ifndef MP */
		top: 88rpx;
		/* #endif */
		z-index: 15;
	}
	.content {
		width: 100vw;
		min-height: 100vh;
		padding-top: 88rpx;
		background: #09081C;
		box-sizing: border-box;
	}
</style>
